package com.dgut.service.background.controller;

import com.alibaba.fastjson.JSON;
import com.dgut.service.background.config.resultConfig.JsonResult;
import com.dgut.service.background.config.resultConfig.ResultTool;
import com.dgut.service.background.entity.TransInspector;
import com.dgut.service.background.service.CheckService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
/**
 * 审核
 */
@RestController
@RequestMapping("check")
public class CheckController {

    @Autowired
    private CheckService checkService;

    @GetMapping("checkData/{page}")
    public String getCheckData(@PathVariable("page")int page){
        Page<TransInspector> allCheckData = checkService.getAllCheckData(page);
        JsonResult result = ResultTool.success(allCheckData);
        return JSON.toJSONString(result);
    }

    @GetMapping("approved/{transId}")
    public String approvedInspector(@PathVariable("transId") int transId){
        checkService.approvedCheck(transId);
        JsonResult result = ResultTool.success();
        return JSON.toJSONString(result);
    }

    @GetMapping("refused/{transId}")
    public String refusedInspector(@PathVariable("transId") int transId){
        checkService.refusedCheck(transId);
        JsonResult result = ResultTool.success();
        return JSON.toJSONString(result);
    }
}
